import Vue from 'vue'
import VueRouter from 'vue-router'

import denglu from '@/views/denglu'
import shouyejiazi from '@/views/shouyejiazi'
import shousuo from '@/views/shousuo'
import shousuolist from '@/views/shousuo/list'
import shangpin from '@/views/shangpin'
import jiesuan from '@/views/jiesuan'
import dingdan from '@/views/dingdan'

import home from '@/views/shouyejiazi/home'
import category from '@/views/shouyejiazi/category'
import cart from '@/views/shouyejiazi/cart'
import user from '@/views/shouyejiazi/user'

Vue.use(VueRouter)

const router = new VueRouter({
  base: process.env.BASE_URL,
  routes: [
    { path: '/denglu', component: denglu },
    {
      path: '/',
      component: shouyejiazi,
      redirect: '/home',
      children: [
        { path: '/home', component: home },
        { path: '/category', component: category },
        { path: '/cart', component: cart },
        { path: '/user', component: user }
      ]
    },
    { path: '/shousuo', component: shousuo },
    { path: '/shousuolist', component: shousuolist },
    { path: '/shangpin/:id', component: shangpin },
    { path: '/jiesuan', component: jiesuan },
    { path: '/dingdan', component: dingdan }
  ]
})

// 全局前置导航守卫
// router.beforeEach((to, from, nemt) => {
//   next()
// })

export default router
